Although
you can set up linked servers and login mappings by directly executing
system stored procedures, you can also set them up easily through SQL
Server Management Studio.
To create a “SQL Server” linked server, you follow these steps:
1. | Open SQL Server Management Studio with a connection to a local server (DBARCHLT\SQL08DE05 in this example).
|
2. | Expand the Server Objects node and then the Linked Servers node.
|
3. | Right-click the Linked Servers node and choose New Linked Server.
|
4. | You
are presented with a properties page where you must specify all the
connection properties for the linked server. For this example, create a
SQL Server database linked server entry. As shown in Figure 1, provide the linked server name DBARCHLT\SQL08DE04T
(or whatever your server and instance name might be) and click the SQL
Server radio button. All the other fields are not needed (and are
grayed out).
|
5. | After you finish the linked server specification, click OK. An entry is added under the Linked Server
node in SQL Server Management Studio. You may receive an error message
complaining about not having the proper authentication for the linked
server access. Not to worry; we’ll fix that in a minute. The linked
server can be used by a SQL query based on the default local logins
being mapped to the linked server. However, you really want to control
the access to this linked server.
|
6. | Right-click
the newly created linked server entry and choose Properties. When the
properties page comes up, select the Security entry on this page. Figure 2 shows explicitly a local login on the local server (DBARCHLT\Paul Bertucci)
that you can use to impersonate your login at the linked server (where
you are already a valid user on the linked server). Now, also indicate
that for any logins not in this list, connections will be made using
the login’s current security context. This locks it down as tightly as
you need it. Click OK, and you are ready to test the linked server.
|
Figure 3 shows the successful execution of a query by user DBARCHLT\Paul Bertucci, using the linked server.
Figure 4
shows an example of creating an Access database linked server entry. As
you can see, you specify the linked server name
ACCESS_DATABASE_CUSTOMERS,
click the Other Data Source radio button, pick Microsoft Jet 4.0 OLE DB
Provider for Provider, specify Access for the Product Name entry, and
supply the full path to the Access database for which you are trying to
create the linked server entry (c:\temp\CustomerPlus.mdb).
There is no need to specify a provider string for this type of linked
server entry. When you click the OK button at the bottom, this linked
server is ready to use for a SQL query.
You are now ready to charge ahead in the realm of using linked servers for everyday purposes. As you can see in Figure 5,
linked servers can take their place in your SQL Server data access
layer alongside any traditional SQL table. This capability expands your
data access horizons much further than you could have reached before.